import PAGE from '../../../utils/middleware/page'
Page(PAGE({
    data: {
        loaded: false,
        list: [],
        apiField: {
            module: 'monthPrice',
            api: 'List',
            data: 'list',
            search: {
                ParkId: null,
            }
        },
        tabList: [
            { name: '全部', id: '' },
            { name: '停车+充电', id: 3 },
            { name: '仅停车', id: 1 },
            { name: '仅充电', id: 2 },
        ],
        tabId: '',
        memberId: '',
        showList: []
    },
    onLoad(options) {
        this.setData({
            'memberId': options.memberId,
            'apiField.search.ParkId': options.parkId
        })
        this.fetchData()
    },
    fetchData() {
        this.handleFetchData({
            complete: (data) => {
                this.setData({
                    showList: data
                })
            }
        }, 'apiField', true)
    },
    changeTab(e) {
        var id = e.currentTarget.dataset.id
        let list = id ? list = this.data.list.filter(x => x.MonthType == id) : this.data.list

        this.setData({
            tabId: id,
            showList: list
        })
    }
}))